﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using System.Windows.Forms;
using System.Net;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        public class Source
        {
            public string Id { get; set; }
            public string Name { get; set; }
            public DateTime CreationTime { get; set; }
            public int P1 { get; set; }
            public int P2 { get; set; }
            public int P3 { get; set; }
            public int P4 { get; set; }
            public int P5 { get; set; }
            public int P6 { get; set; }
            public int P7 { get; set; }
            public int P8 { get; set; }
            public int P9 { get; set; }
            public int P10 { get; set; }
            public int P11 { get; set; }
            public int P22 { get; set; }
        }

        public class Destination
        {
            public string Id { get; set; }
            public string Name { get; set; }
            public DateTime CreationTime { get; set; }
            public int P1 { get; set; }
            public int P2 { get; set; }
            public int P3 { get; set; }
            public int P4 { get; set; }
            public int P5 { get; set; }
            public int P6 { get; set; }
            public int P7 { get; set; }
            public int P8 { get; set; }
            public int P9 { get; set; }
            public int P10 { get; set; }
            public int P11 { get; set; }
            public int P22 { get; set; }
        }

        [TestMethod]
        public void TestMethod1()
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();

            Source s = new Source()
            {
                Id = Guid.NewGuid().ToString(),
                Name = "HY",
                CreationTime = DateTime.Now,
                P1 = 1,
                P2 = 2,
                P3 = 3,
                P4 = 4,
                P5 = 5,
                P6 = 6,
                P7 = 7,
                P8 = 8,
                P9 = 9,
                P10 = 10,
                P11 = 11,
                P22 = 22
            };

            Destination d = new Destination();

            var mapper = WLFramework.Mapping.ObjectMapper.CreateMapper<Source, Destination>();

            for (int i = 0; i < 100000; i++)
            {
                mapper.Mapping(s, d);
            }

            

            MessageBox.Show("takes " + watch.ElapsedMilliseconds + " ms");
            MessageBox.Show(Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString());
            Assert.AreEqual(s.Id, d.Id);
            Assert.AreEqual(s.Name, d.Name);
            Assert.AreEqual(s.CreationTime, d.CreationTime);
        }
    }
}
